package gui;

import java.io.File;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import resources.images.ImagesPath;

import com.swtdesigner.SWTResourceManager;

public class AboutDialog extends Dialog {

	private Text johanzilberText;
	private StyledText riskGameStyledText;
	private Text copyrightText;
	protected Object result;
	protected Shell shell;

	/**
	 * Create the dialog
	 * @param parent
	 * @param style
	 */
	public AboutDialog(Shell parent, int style) {
		super(parent, style);
	}

	/**
	 * Create the dialog
	 * @param parent
	 */
	public AboutDialog(Shell parent) {
		this(parent, SWT.NONE);
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		return result;
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
		shell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		shell.setLocation(RiskGUI.getNewPosition(getParent()));
		shell.setSize(464, 266);
		shell.setText("About");

		final Label label = new Label(shell, SWT.NONE);
		label.setBounds(25,18,10,10);
		Image logoImage = new Image(Display.getDefault(),ImagesPath.getImageStream("world_mini.JPG"));
		label.setBackgroundImage(logoImage);
		label.setSize(logoImage.getBounds().width, logoImage.getBounds().height);
		
		final Button okButton = new Button(shell, SWT.NONE);
		okButton.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent arg0) {
				shell.dispose();
			}
		});
		okButton.setText("Close");
		okButton.setBounds(369, 201, 73, 23);

		copyrightText = new Text(shell, SWT.BORDER);
		copyrightText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		copyrightText.setEditable(false);
		copyrightText.setText("Copyright 2009  Tel Aviv University, All Rights Reserved  ");
		copyrightText.setBounds(160, 46, 281, 23);

		riskGameStyledText = new StyledText(shell, SWT.BORDER);
		riskGameStyledText.setEditable(false);
		riskGameStyledText.setBackground(SWTResourceManager.getColor(255, 128, 128));
		riskGameStyledText.setText(" Risk Game");
		riskGameStyledText.setBounds(161, 17, 281, 23);

		johanzilberText = new Text(shell, SWT.BORDER | SWT.MULTI);
		johanzilberText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		johanzilberText.setEditable(false);
		johanzilberText.setText("Irena Bershadsky\nDovrat Shoval\nTal Shapiro\nJenia Zilber\nEugene Rozenberg\nShay Sheinfeld\nErez Kastel\nPavel Roit");
		johanzilberText.setBounds(160, 75, 282, 116);

		//
	}

}
